﻿using Himp.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Himp.Outpatient
{
    /// <summary>
    /// 门诊就诊记录
    /// </summary>
    public class OtpMdtrtRec : AuditedAggregateRoot<Guid>, IMultiTenant
    {
        /// <summary>
        /// 就医流水号
        /// </summary>
        public string MdtrtSn { get; private set; }

        /// <summary>
        /// 患者Id
        /// </summary>
        public Guid PatnId { get; set; }

        /// <summary>
        /// 门诊号
        /// </summary>
        public string OtpNo { get; set; }

        /// <summary>
        /// 人员姓名
        /// </summary>
        public string PatnName { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public EnumGender Gender { get; set; }

        /// <summary>
        /// 年龄
        /// </summary>
        public int Age { get; set; }

        /// <summary>
        /// 门诊挂号类别ID
        /// </summary>
        public Guid OtpRgstTypeId { get; set; }

        /// <summary>
        /// 科室Id
        /// </summary>
        public Guid DeptId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DeptCodg { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DeptName { get; set; }

        /// <summary>
        /// 医师Id
        /// </summary>
        public Guid DrId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DrCodg { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DrName { get; set; }

        /// <summary>
        /// 就诊时间
        /// </summary>
        public DateTime? MdtrtTime { get; set; }

        /// <summary>
        /// 主诉
        /// </summary>
        public string? Chfcomp { get; set; }

        /// <summary>
        /// 病史
        /// </summary>
        public string? Illhis { get; set; }

        /// <summary>
        /// 过敏史
        /// </summary>
        public string? Algs { get; set; }

        /// <summary>
        /// 过敏源代码
        /// </summary>
        public string? AiseCode { get; set; }

        /// <summary>
        /// 体格检查
        /// 查体
        /// </summary>
        public string? Phex { get; set; }

        /// <summary>
        /// 辅助检查
        /// </summary>
        public string? AsstExam { get; set; }

        /// <summary>
        /// 处方记录
        /// </summary>
        public string? RxRec { get; set; }

        /// <summary>
        /// 症状名称
        /// </summary>
        public string? SympName { get; set; }

        /// <summary>
        /// 症状代码
        /// </summary>
        public string? SympCode { get; set; }

        /// <summary>
        /// 处理措施
        /// 处置意见
        /// </summary>
        public string? DspoOpnn { get; set; }

        /// <summary>
        /// 发病时间
        /// </summary>
        public DateTime? AttkTime { get; set; }

        /// <summary>
        /// 初诊标识
        /// </summary>
        public bool FstdiagFlag { get; set; }

        /// <summary>
        /// 门诊就诊状态
        /// </summary>
        public EnumOtpMdtrtStas OtpMdtrtStas { get; set; }

        /// <summary>
        /// 门诊诊断记录
        /// </summary>
        public List<OtpDiagRec> OtpDiagRecs { get; set; }

        ///// <summary>
        ///// 门诊处方记录
        ///// </summary>
        //public List<OtpRxRec> OtpRxRecs { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }
        
        public OtpMdtrtRec()
        { 
        
        }

        public OtpMdtrtRec(string mdtrtSn, Guid patnId, string otpNo, string patnName
            , Guid otpRgstTypeId, Guid deptId, Guid drId)
        {
            MdtrtSn = mdtrtSn;
            PatnId = patnId;
            OtpNo = otpNo;
            PatnName = patnName;
            OtpRgstTypeId = otpRgstTypeId;
            DeptId = deptId;
            DrId = drId;
        }

        public OtpMdtrtRec(string mdtrtSn, Guid patnId, string otpNo, string patnName
            , Guid deptId, Guid drId)
        {
            MdtrtSn = mdtrtSn;
            PatnId = patnId;
            OtpNo = otpNo;
            PatnName = patnName;
            DeptId = deptId;
            DrId = drId;
        }

        /// <summary>
        /// 更新就诊信息
        /// </summary>
        public void ChangeMdtrtInfo(bool fstdiagFlag,string? chfcomp, string? diseNow, string? physexm
            , string? asstExam, string? dspoMes, DateTime? attkTime)
        { 
            FstdiagFlag = fstdiagFlag;
            Chfcomp = chfcomp;
            Illhis = diseNow;
            Phex = physexm;
            AsstExam = asstExam;
            DspoOpnn = dspoMes;
            AttkTime = attkTime;
        }

        public void SetMdtrt()
        {
            OtpMdtrtStas = EnumOtpMdtrtStas.就诊中;
            MdtrtTime = DateTime.Now;
        }
    }
}
